<?php

/**
 * @author Jeevan Tomson
 * @copyright 2011
 */

function printObject( $obj ) {
    echo "<pre>";
    print_r($obj);
    echo "</pre>";
}

function prepareMySqlData() {
	if( isset($_GET) )
	{
		foreach( $_GET as $key => $value )
		{
		    $value = trim($value);  
			$_GET[$key] = mysql_real_escape_string($value);
		}
	}
	if( isset($_POST))
	{
		foreach( $_POST as $key => $value ) {
            $value = trim($value);
			$_POST[$key] = mysql_real_escape_string($value);
		}
	}
}

function getLanguage() {
    if( isset($_SESSION["lang"]) ) {
        return $_SESSION["lang"];
    } else if( isset($_COOKIE["lang"]) ) {
        return $_COOKIE["lang"];
    } else {
        return DEFAULT_LANG;
    }
}

function label($id) {
    echo getLabel($id);
}

function getLabel($id) {
    return LabelManager::getLabel($id);
}

function setLanguageCookie( $langcode ) {
   setcookie("lang",$langcode,time()+(3600*24*7));        
}

function getLanguageCookie() {
    if( isset($_COOKIE["lang"]) && $_COOKIE["lang"] ) {
        return $_COOKIE["lang"];
    }    
}

function applyStripSlashes($row) {
    foreach( $row  as &$field ) {
        $field = stripslashes($field);        
    }
}

function PASSWORD($input, $hex = true) {
  $sha1_stage1 = sha1($input, true);
  $output = strtoupper("*".sha1($sha1_stage1, !$hex));
  return $output;
}   
    
?>